#ifndef GL3WIN_H_
#define GL3WIN_H_
#include <glapif.h>
#include <glf.h>

#ifdef __cplusplus
extern "C" {
#endif
/* This function sets up and destroys a dummy context we need in order to query some
    information which requires a valid and bound OpenGL context.
    It's also needed for glXGetProcAddress and wglGetProcAddress, which we need to
    query some extended window-specific API functions used for visual/pixelformat configuration
    and context creattion. Chicken and the egg and all that..
*/
int glfCreateDummyContext(void);

typedef void (*glfCallback)(void* userdata);

#if !defined(GLF_PLATFORM_WIN32)
typedef struct
{
	int left,top, right, bottom;
} RECT;
#else
#include <Windows.h>
#endif

int glfGetWidth();
int glfGetHeight();
int glfGetWindowPosition( int *x, int *y );
int glfGetDisplayOffset( int *x, int *y );
void glfConfigSetAttribute(int name, int attrib);
void glfSetCursorFlags( int flags );
int glfCreateWindow(const char* title, int width, int height);
void glfDestroyWindow(void);
int glfSetCallBack(int type, glfCallback callback, void* userdata);
int glfMainloop(void);

typedef struct
{
#if defined( GLF_PLATFORM_WIN32 )
    HINSTANCE hinstance;
	HDC hdc;
    HGLRC hrc;
    HWND hwnd;
	int active;
#else
    GLXContext rc;
    Window window;
    Display *display;
#endif
    RECT rect;
    glfCallback callbackInitialise;
	glfCallback callbackThink;
    glfCallback callbackRender;
    glfCallback callbackResize;
	glfCallback callbackTerminate;
    
	void* dataInitialise;
    void* dataThink;
    void* dataRender;
    void* dataResize;
	void* dataTerminate;
} glfWindowInfo;

/*
float pixelformat:
    WGL_TYPE_RGBA_FLOAT_ARB as an attribute to wglChoosePixelFormatARB
    GLX_RGBA_FLOAT_BIT to GLX_RENDER_TYPE in attribs to visuals/FBconfigs
    GLX_RGBA_FLOAT_TYPE to GLX_RENDER_TYPE in glXCreateContextAttribs
*/

/* 32-bit RGBA, Double-buffering, 24 bit depth and 8-bit stencil is always implied.
No accumulation or aux buffers. Only one pixelplane.*/

typedef enum /* attribute names for 'attribs' in glfCreateWindow */
{
    /*  glfRGBA, and glfFloat are mutually exclusive.
        glfSRGB can be enabled for either one.*/
    glfFramebufferType = 128,
    glfMultiSampleLevel = 256, /* 0 or 1 is single-sample. Higher is more samples */
    glfMajorVersion = 512, /* OpenGL major version for CreateContextAttribs */
    glfMinorVersion = 1024, /* OpenGL minor version for CreateContextAttribs */
    glfContextFlags = 2048,  /* Let you ask for debug contexts and forward-compatible contexts */
	glfFullscreen = 4096,	/* Fullscreen window */
	glfSizable = 8192,		/* Sizable window, ignored in fullscreen mode */
	glfDisableVsync = 16384		/* Vsync */
} glfAttribName;

typedef enum
{
    glfNone=0,
    glfFalse=1,
    glfTrue=2,
    /* Fixedpoint RGBA framebuffer. Mutually exclusive with glfFloat*/
    glfRGBA=4,
    /*  Floating-point framebuffer. This enables you to toggle colour clamping
        in OpenGL 3.x. Mutually exclusive with glfRGBA*/
    glfFloat=8,
    /*  True if the pixelformat/fbConfig should support sRGB-rendering.
        NOTE: This is not a new pixelformat per-se. Framebuffer colours are still fixedpoint RGBA,
        or floating-point RGBA types. sRGB only enables the use of the sRGB colour space, which unlike
        RGB is non-linear. Refer to the extensions GL_ARB_framebuffer_sRGB and GL_EXT_texture_sRGB,
        or the OpenGL 3.0 or OpenGL 3.1 standards for more information. */
    glfSRGB=16,
    glfContextForwardCompatible=32,
    glfContextDebug=64
} glfAttribAttrib;

typedef enum
{
	glfCursorHide=1,
	glfCursorLock=2
} glfCursorFlag;

typedef enum
{
	glfCallbackInitialise=1,
    glfCallbackThink=2,
    glfCallbackRender=3,
	glfCallbackTerminate=4,
    glfCallbackResize=57
    //glfCallbackExpose /* not used yet. Assume we want to render once every mainloop iteration */
} glfCallbackType;

#ifdef __cplusplus
}
#endif

#endif


